#!/usr/bin/env python

import argparse

import pyglet

import lib.config
import lib.constants
import lib.controller


def setup_resources():
    pyglet.resource.path = ['.', 'data', 'data/img', 'data/levels', 'data/music']
    pyglet.resource.reindex()


def main(level_name):
    setup_resources()
    lib.controller.Controller().run(level_name)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description=lib.constants.GAME_NAME)
    parser.add_argument("-d", "--debug", action="store_true",
                        help="Turn on debugging")
    parser.add_argument("level_name", nargs="?", default=None)

    d = parser.parse_args()

    lib.config.debug = d.debug

    main(d.level_name)
